home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / sysdeps / i386 / sub_n.S < prev    next >
Text File  |  1994-05-16  |  2KB  |  94 lines

  1. # i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store
  2. # sum in a third limb vector.
  3.  
  4. # Copyright (C) 1992, 1994 Free Software Foundation, Inc.
  5.  
  6. # This file is part of the GNU MP Library.
  7.  
  8. # The GNU MP Library is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Library General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or (at your
  11. # option) any later version.
  12.  
  13. # The GNU MP Library is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15. # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
  16. # License for more details.
  17.  
  18. # You should have received a copy of the GNU Library General Public License
  19. # along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
  20. # the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. # INPUT PARAMETERS
  24. # res_ptr    (sp + 4)
  25. # s1_ptr    (sp + 8)
  26. # s2_ptr    (sp + 12)
  27. # size        (sp + 16)
  28.  
  29. #include "asm.h"
  30. #include "sysdep.h"
  31.  
  32. .text
  33.     .align 2
  34.     .globl C_SYMBOL_NAME(__mpn_sub_n)
  35. C_SYMBOL_NAME(__mpn_sub_n):
  36.     pushl %edi
  37.     pushl %esi
  38.  
  39.     movl 12(%esp),%edi    # res_ptr
  40.     movl 16(%esp),%esi    # s1_ptr
  41.     movl 20(%esp),%edx    # s2_ptr
  42.     movl 24(%esp),%ecx    # size
  43.  
  44.     movl    %ecx,%eax
  45.     shrl    $3,%ecx            # compute loop count for unrolled loop
  46.     negl    %eax
  47.     andl    $7,%eax            # get index where to start loop
  48.     jz    Loop            # necessary special case for 0
  49.     incl    %ecx            # adjust loop count
  50.     shll    $2,%eax            # adjustment for pointers...
  51.     subl    %eax,%edi        # ... since they are offset ...
  52.     subl    %eax,%esi        # ... by a constant when we enter ...
  53.     subl    %eax,%edx        # ... the loop
  54.     shrl    $2,%eax            # restore previous value
  55.     leal    (Loop - 3)(%eax,%eax,8),%eax    # calc start addr in loop
  56.     jmp    *%eax            # jump into loop
  57.     .align    2
  58. Loop:    movl    (%esi),%eax
  59.     sbbl    (%edx),%eax
  60.     movl    %eax,(%edi)
  61.     movl    4(%esi),%eax
  62.     sbbl    4(%edx),%eax
  63.     movl    %eax,4(%edi)
  64.     movl    8(%esi),%eax
  65.     sbbl    8(%edx),%eax
  66.     movl    %eax,8(%edi)
  67.     movl    12(%esi),%eax
  68.     sbbl    12(%edx),%eax
  69.     movl    %eax,12(%edi)
  70.     movl    16(%esi),%eax
  71.     sbbl    16(%edx),%eax
  72.     movl    %eax,16(%edi)
  73.     movl    20(%esi),%eax
  74.     sbbl    20(%edx),%eax
  75.     movl    %eax,20(%edi)
  76.     movl    24(%esi),%eax
  77.     sbbl    24(%edx),%eax
  78.     movl    %eax,24(%edi)
  79.     movl    28(%esi),%eax
  80.     sbbl    28(%edx),%eax
  81.     movl    %eax,28(%edi)
  82.     leal    32(%edi),%edi
  83.     leal    32(%esi),%esi
  84.     leal    32(%edx),%edx
  85.     decl    %ecx
  86.     jnz    Loop
  87.  
  88.     sbbl    %eax,%eax
  89.     negl    %eax
  90.  
  91.     popl %esi
  92.     popl %edi
  93.     ret
  94.